Add an optimizer to add distinct below build side of semi join#25238
Merged
feilong-liu merged 1 commit intoprestodb:masterfrom Jun 5, 2025
Merged
Add an optimizer to add distinct below build side of semi join#25238feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu merged 1 commit intoprestodb:masterfrom
Conversation
6d6ebc0 to
9ce3afa
Compare
9ce3afa to
a6095f6
Compare
kaikalur
requested changes
Jun 3, 2025
...rc/main/java/com/facebook/presto/sql/planner/iterative/rule/AddDistinctForSemiJoinBuild.java
Show resolved
Hide resolved
a6095f6 to
9f67498
Compare
kaikalur
previously approved these changes
Jun 4, 2025
9f67498 to
52819a6
Compare
kaikalur
approved these changes
Jun 4, 2025
jaystarshot
reviewed
Jun 4, 2025
| private boolean nativeExecutionTypeRewriteEnabled; | ||
| private String expressionOptimizerName = DEFAULT_EXPRESSION_OPTIMIZER_NAME; | ||
| private boolean addExchangeBelowPartialAggregationOverGroupId; | ||
| private boolean addDistinctBelowSemiJoinBuild; |
Contributor
Author
There was a problem hiding this comment.
I'd like to run it for some time before turning it on as default.
jaystarshot
approved these changes
Jun 5, 2025
| import static com.facebook.presto.spi.plan.AggregationNode.isDistinct; | ||
| import static com.facebook.presto.spi.plan.AggregationNode.singleGroupingSet; | ||
| import static com.facebook.presto.sql.planner.plan.Patterns.semiJoin; | ||
|
|
Member
There was a problem hiding this comment.
Please add small comment explaining the rule
6 tasks
6 tasks
This was referenced Jul 4, 2025
This was referenced Jul 24, 2025
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We found that adding a distinct aggregation before a semi join on the build side can improve latency. This is probably due to the restriction that the build side of semi join is executed with single thread
presto/presto-main-base/src/main/java/com/facebook/presto/sql/planner/LocalExecutionPlanner.java
Line 2623 in a12b523
This PR works by adding a distinct aggregation below the semi join on the build side.
Motivation and Context
To improve latency of semi join
Impact
To improve latency of semi join
Test Plan
Unit tests
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.